package com.myself.hello.web.controller;


import com.myself.hello.web.dao.ZhangkeruiAccountingRecordMapper;
import com.myself.hello.web.dataobject.ZhangkeruiAccountingRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RestController
public class ZhangkeruiAccountingController {

    @Autowired
    ZhangkeruiAccountingRecordMapper zhangkeruiAccountingRecordMapper;

    @RequestMapping("/add")
    public String add()
    {
        ZhangkeruiAccountingRecord zhangkeruiAccountingRecord = new ZhangkeruiAccountingRecord();
        zhangkeruiAccountingRecord.setAmount(100.0);
        zhangkeruiAccountingRecord.setDesc("支出");
        zhangkeruiAccountingRecord.setCategory("支出");
        zhangkeruiAccountingRecord.setId((long) 1);

        zhangkeruiAccountingRecord.setRecordType("生活其他");
        zhangkeruiAccountingRecordMapper.insert(zhangkeruiAccountingRecord);
        return "success";
    }

    @RequestMapping("/list")
    public List<ZhangkeruiAccountingRecord> list()
    {
        List<ZhangkeruiAccountingRecord> zhangkeruiAccountingRecords = zhangkeruiAccountingRecordMapper.selectAll();
        return  zhangkeruiAccountingRecords;
    }
}
